package org.ala.tiktools.rpc.kcp.client_server;

import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

import org.ala.tiktools.rpc.kcp.netty.client.KcpClientChannel;
import org.ala.tiktools.rpc.netty.handler.RpcChannelInitializer;
import org.ala.tiktools.rpc.plugin.node.AbstractNode;
import org.ala.tiktools.rpc.plugin.node.NodeKey;

import io.netty.channel.Channel;

/**
 *	kcp节点
 *
 *	@author ala
 *	@date 2025年4月19日
 */
public class KcpNode extends AbstractNode {
	
	
	/**
	 * 	持有的channel
	 */
	protected KcpClientChannel channel;
	
	@Override
	protected String type() {
		return "kcp";
	}

	public KcpNode(String group, NodeKey nodeKey) {
		super(group, nodeKey);
	}

	@Override
	protected CompletableFuture<Channel> connect(Consumer<Channel> registered, Consumer<Channel> unRegistered) {
		return KcpNettyTools.connect(key().getHost(), key().getPort(), new RpcChannelInitializer(null, true, false, registered, unRegistered));
	}

}
